home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-
- #include "shared.fx"
-
- //------------------------------------------------------------------------------------------------------
- //- Static parameters
- //------------------------------------------------------------------------------------------------------
-
- //common things
- shared texture SourceTexture1;
- shared texture SourceTexture2;
- shared texture SourceTexture3;
- shared texture SourceTexture4;
-
- shared float TextureWidth1;
- shared float TextureWidth2;
- shared float TextureWidth3;
- shared float TextureWidth4;
-
- shared float TextureHeight1;
- shared float TextureHeight2;
- shared float TextureHeight3;
- shared float TextureHeight4;
-
- shared float4 BlendWeight1;
- shared float4 BlendWeight2;
- shared float4 BlendWeight3;
- shared float4 BlendWeight4;
-
- shared float NeighbourSamplingOffsetU;
- shared float NeighbourSamplingOffsetV;
-
-
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-
- struct VS_PostProcess_Input
- {
- float4 Position : POSITION;
- float2 DiffuseUv : TEXCOORD0;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- struct VS_PostProcess_Output1
- {
- float4 Position : POSITION;
- float2 DiffuseUv : TEXCOORD0;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- struct VS_PostProcess_Output2
- {
- float4 Position : POSITION;
- float2 DiffuseUv1 : TEXCOORD0;
- float2 DiffuseUv2 : TEXCOORD1;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- struct VS_PostProcess_Output3
- {
- float4 Position : POSITION;
- float2 DiffuseUv1 : TEXCOORD0;
- float2 DiffuseUv2 : TEXCOORD1;
- float2 DiffuseUv3 : TEXCOORD2;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- struct VS_PostProcess_Output4
- {
- float4 Position : POSITION;
- float2 DiffuseUv1 : TEXCOORD0;
- float2 DiffuseUv2 : TEXCOORD1;
- float2 DiffuseUv3 : TEXCOORD2;
- float2 DiffuseUv4 : TEXCOORD3;
- };
-
- //------------------------------------------------------------------------------------------------------
-
- struct VS_PostProcess_Output_NeighbourSampling
- {
- float4 Position : POSITION;
- float2 DiffuseN0 : TEXCOORD0;
- float2 DiffuseN1 : TEXCOORD1;
- float2 DiffuseN2 : TEXCOORD2;
- float2 DiffuseN3 : TEXCOORD3;
- };
-
- //------------------------------------------------------------------------------------------------------
- // VERTEX SHADERS DECLARATIONS
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output1 VSBase(const VS_PostProcess_Input input);
-
- VS_PostProcess_Output1 VSBaseScreenCorrected1(const VS_PostProcess_Input input);
- VS_PostProcess_Output2 VSBaseScreenCorrected2(const VS_PostProcess_Input input);
- VS_PostProcess_Output3 VSBaseScreenCorrected3(const VS_PostProcess_Input input);
- VS_PostProcess_Output4 VSBaseScreenCorrected4(const VS_PostProcess_Input input);
-
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingCross(const VS_PostProcess_Input input);
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingBox(const VS_PostProcess_Input input);
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingLine(const VS_PostProcess_Input input);
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingColumn(const VS_PostProcess_Input input);
-
- //------------------------------------------------------------------------------------------------------
- // VERTEX SHADERS IMPLEMENTATIONS
- //------------------------------------------------------------------------------------------------------
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output1 VSBase(const VS_PostProcess_Input input);
- //
- // simple position + uv transfer (UV correction is applied though)
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output1 VSBase(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output1 output;
-
- // output position into world+view+projection space
- output.Position = input.Position;
-
- // Diffuse Uv output
- output.DiffuseUv = input.DiffuseUv;
-
- return output;
- }
-
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output1 VSBaseScreenCorrected1(const VS_PostProcess_Input input);
- //
- // simple position + uv transfer (UV correction is applied though)
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output1 VSBaseScreenCorrected1(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output1 output;
-
- // output position into world+view+projection space
- output.Position = input.Position;
-
- // Diffuse Uv output
- output.DiffuseUv = input.DiffuseUv + (0.5f/TextureWidth1, 0.5f/TextureHeight1);
-
- return output;
- }
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output2 VSBaseScreenCorrected2(const VS_PostProcess_Input input);
- //
- // simple position + uv transfer (UV correction is applied though)
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output2 VSBaseScreenCorrected2(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output2 output;
-
- // output position into world+view+projection space
- output.Position = input.Position;
-
- // Diffuse Uv output
- output.DiffuseUv1 = input.DiffuseUv + (0.5f/TextureWidth1, 0.5f/TextureHeight1);
- output.DiffuseUv2 = input.DiffuseUv + (0.5f/TextureWidth2, 0.5f/TextureHeight2);
-
- return output;
- }
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output3 VSBaseScreenCorrected3(const VS_PostProcess_Input input);
- //
- // simple position + uv transfer (UV correction is applied though)
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output3 VSBaseScreenCorrected3(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output3 output;
-
- // output position into world+view+projection space
- output.Position = input.Position;
-
- // Diffuse Uv output
- output.DiffuseUv1 = input.DiffuseUv + (0.5f/TextureWidth1, 0.5f/TextureHeight1);
- output.DiffuseUv2 = input.DiffuseUv + (0.5f/TextureWidth2, 0.5f/TextureHeight2);
- output.DiffuseUv3 = input.DiffuseUv + (0.5f/TextureWidth3, 0.5f/TextureHeight3);
-
- return output;
- }
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output4 VSBaseScreenCorrected4(const VS_PostProcess_Input input);
- //
- // simple position + uv transfer (UV correction is applied though)
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output4 VSBaseScreenCorrected4(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output4 output;
-
- // output position into world+view+projection space
- output.Position = input.Position;
-
- // Diffuse Uv output
- output.DiffuseUv1 = input.DiffuseUv + (0.5f/TextureWidth1, 0.5f/TextureHeight1);
- output.DiffuseUv2 = input.DiffuseUv + (0.5f/TextureWidth2, 0.5f/TextureHeight2);
- output.DiffuseUv3 = input.DiffuseUv + (0.5f/TextureWidth3, 0.5f/TextureHeight3);
- output.DiffuseUv4 = input.DiffuseUv + (0.5f/TextureWidth4, 0.5f/TextureHeight4);
-
- return output;
- }
-
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output_NeighbourSampling VSNeighbourSampling(const VS_PostProcess_Input input)
- // 0X0
- // cross sampling X0X (X are samples)
- // 0X0
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingCross(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output_NeighbourSampling output;
-
- // output position into world+view+projection space
- output.Position = input.Position;
-
- // Diffuse Uv output using neighbour sampling!!
- float OffsetU = NeighbourSamplingOffsetU/TextureWidth1;
- float OffsetV = NeighbourSamplingOffsetV/TextureHeight1;
-
- output.DiffuseN0 = saturate(input.DiffuseUv + float2(-OffsetU,0.0f)); // left
- output.DiffuseN1 = saturate(input.DiffuseUv + float2(+OffsetU,0.0f)); // right
- output.DiffuseN2 = saturate(input.DiffuseUv + float2(0.0f,+OffsetV)); // up
- output.DiffuseN3 = saturate(input.DiffuseUv + float2(0.0f,-OffsetV)); // down
-
- return output;
- }
-
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingBox(const VS_PostProcess_Input input)
- // X0X
- // box sampling 000 (X are samples)
- // X0X
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingBox(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output_NeighbourSampling output;
-
- output.Position = input.Position;
-
- float OffsetU = NeighbourSamplingOffsetU/TextureWidth1;
- float OffsetV = NeighbourSamplingOffsetV/TextureHeight1;
-
- output.DiffuseN0 = saturate(input.DiffuseUv + float2(-OffsetU,+OffsetV)); // top left
- output.DiffuseN1 = saturate(input.DiffuseUv + float2(+OffsetU,+OffsetV)); // top right
- output.DiffuseN2 = saturate(input.DiffuseUv + float2(-OffsetU,-OffsetV)); // bottom left
- output.DiffuseN3 = saturate(input.DiffuseUv + float2(+OffsetU,-OffsetV)); // bottom right
-
- return output;
- }
-
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingLine(const VS_PostProcess_Input input)
- //
- // line sampling XX0XX (X are samples)
- //
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingLine(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output_NeighbourSampling output;
-
- output.Position = input.Position;
-
- float2 OffsetNear = float2(NeighbourSamplingOffsetU/TextureWidth1, 0.0f);
- float2 OffsetFar = 2.0f*OffsetNear;
-
- output.DiffuseN0 = saturate(input.DiffuseUv - OffsetFar);
- output.DiffuseN1 = saturate(input.DiffuseUv - OffsetNear);
- output.DiffuseN2 = saturate(input.DiffuseUv + OffsetNear);
- output.DiffuseN3 = saturate(input.DiffuseUv + OffsetFar);
-
- return output;
- }
-
-
- //------------------------------------------------------------------------------------------------------
- // VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingColumn(const VS_PostProcess_Input input)
- // X
- // X
- // column sampling 0 (X are samples)
- // X
- // X
- //------------------------------------------------------------------------------------------------------
- VS_PostProcess_Output_NeighbourSampling VSNeighbourSamplingColumn(const VS_PostProcess_Input input)
- {
- VS_PostProcess_Output_NeighbourSampling output;
-
- output.Position = input.Position;
-
- float2 OffsetNear = float2(0.0f, NeighbourSamplingOffsetV/TextureHeight1);
- float2 OffsetFar = 2.0f*OffsetNear;
-
- output.DiffuseN0 = saturate(input.DiffuseUv - OffsetFar);
- output.DiffuseN1 = saturate(input.DiffuseUv - OffsetNear);
- output.DiffuseN2 = saturate(input.DiffuseUv + OffsetNear);
- output.DiffuseN3 = saturate(input.DiffuseUv + OffsetFar);
-
- return output;
- }
-
-
- //------------------------------------------------------------------------------------------------------
- // TECHNIQUES DEFINITIONS
- //------------------------------------------------------------------------------------------------------
-
-
- //----------------------------------------------
- // simple output to screen of SourceTexture1
- //----------------------------------------------
- technique BaseRender
- <
- int Priority = 1;
- int TechniqueIndex = 100;
- int DeviceType = HWSHADER_ONLY;
- int LightingType = INTEGRATED_LIGHTING;
- string RenderingType = "Standard";
- >
- {
- pass pass1
- {
- Texture[0] = <SourceTexture1>;
- MinFilter[0] = LINEAR;
- MagFilter[0] = LINEAR;
- MipFilter[0] = NONE; //no mipmaps.
- AddressU[0] = CLAMP;
- AddressV[0] = CLAMP;
- AlphaBlendEnable = false;
- AlphaTestEnable = false;
- FogEnable = false;
-
- CullMode = NONE;
- ZEnable = false;
- ZWriteEnable = false;
-
- VertexShader = compile vs_1_1 VSBase();
-
- PixelShader =
- asm
- {
- ps_1_1
-
- tex t0 // source texture
-
- mov r0, t0 // simple output
- };
- }
- }
-
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-
-
- //----------------------------------------------
- // Additive blend of SourceTexture1 with BlendWeight1 with current RT
- //----------------------------------------------
- technique AdditiveBlendWithCurrentRT
- <
- int Priority = 1;
- int TechniqueIndex = 101;
- int DeviceType = HWSHADER_ONLY;
- int LightingType = INTEGRATED_LIGHTING;
- string RenderingType = "Standard";
- >
- {
- pass pass1
- {
- Texture[0] = <SourceTexture1>;
- MinFilter[0] = LINEAR;
- MagFilter[0] = LINEAR;
- MipFilter[0] = NONE; //no mipmaps.
- AddressU[0] = CLAMP;
- AddressV[0] = CLAMP;
- AlphaBlendEnable = true;
- SrcBlend = ONE;
- DestBlend = ONE;
- AlphaTestEnable = false;
- FogEnable = false;
-
- CullMode = NONE;
- ZEnable = false;
- ZWriteEnable = false;
-
- VertexShader = compile vs_1_1 VSBase();
-
- PixelShaderConstant[0] = <BlendWeight1>;
-
- PixelShader =
- asm
- {
- ps_1_1
-
- tex t0 // source texture
-
- mul r0, c0, t0
- };
- }
- }
-
-
- //----------------------------------------------
- // Alpha blend of SourceTexture1 with blend factor BlendWeight1 with current RT content
- //----------------------------------------------
- technique AlphaBlendWithCurrentRT
- <
- int Priority = 1;
- int TechniqueIndex = 102;
- int DeviceType = HWSHADER_ONLY;
- int LightingType = INTEGRATED_LIGHTING;
- string RenderingType = "Standard";
- >
- {
- pass pass1
- {
- Texture[0] = <SourceTexture1>;
- MinFilter[0] = LINEAR;
- MagFilter[0] = LINEAR;
- MipFilter[0] = NONE; //no mipmaps.
- AddressU[0] = CLAMP;
- AddressV[0] = CLAMP;
- AlphaBlendEnable = true;
- SrcBlend = SRCALPHA;
- DestBlend = INVSRCALPHA;
- AlphaTestEnable = false;
- FogEnable = false;
-
- CullMode = NONE;
- ZEnable = false;
- ZWriteEnable = false;
-
- VertexShader = compile vs_1_1 VSBase();
-
- PixelShaderConstant[0] = <BlendWeight1>;
-
- PixelShader =
- asm
- {
- ps_1_1
-
- tex t0 // source texture
-
- mov r0.rgb, t0 + mul r0.a, t0, c0
- };
- }
- }
-
-
-
- //----------------------------------------------
- // blend of 2 textures into one
- //----------------------------------------------
- technique Blend2
- <
- int Priority = 1;
- int TechniqueIndex = 200;
- int DeviceType = HWSHADER_ONLY;
- int LightingType = INTEGRATED_LIGHTING;
- string RenderingType = "Standard";
- >
- {
- pass pass1
- {
- Texture[0] = <SourceTexture1>;
- MinFilter[0] = LINEAR;
- MagFilter[0] = LINEAR;
- MipFilter[0] = NONE; //no mipmaps.
- AddressU[0] = CLAMP;
- AddressV[0] = CLAMP;
-
- Texture[1] = <SourceTexture2>;
- MinFilter[1] = LINEAR;
- MagFilter[1] = LINEAR;
- MipFilter[1] = NONE; //no mipmaps.
- AddressU[1] = CLAMP;
- AddressV[1] = CLAMP;
-
- AlphaBlendEnable = false;
- AlphaTestEnable = false;
- FogEnable = false;
-
- CullMode = NONE;
- ZEnable = false;
- ZWriteEnable = false;
-
- VertexShader = compile vs_1_1 VSBaseScreenCorrected2();
-
- PixelShaderConstant[0] = <BlendWeight1>;
- PixelShaderConstant[1] = <BlendWeight2>;
-
- PixelShader =
- asm
- {
- ps_1_1
-
- tex t0
- tex t1
-
- mul r0, c0, t0
- mad r0, c1, t1, r0
- };
- }
- }
-
-
- //----------------------------------------------
- // blend of 3 textures into one
- //----------------------------------------------
- technique Blend3
- <
- int Priority = 1;
- int TechniqueIndex = 201;
- int DeviceType = HWSHADER_ONLY;
- int LightingType = INTEGRATED_LIGHTING;
- string RenderingType = "Standard";
- >
- {
- pass pass1
- {
- Texture[0] = <SourceTexture1>;
- MinFilter[0] = LINEAR;
- MagFilter[0] = LINEAR;
- MipFilter[0] = NONE; //no mipmaps.
- AddressU[0] = CLAMP;
- AddressV[0] = CLAMP;
-
- Texture[1] = <SourceTexture2>;
- MinFilter[1] = LINEAR;
- MagFilter[1] = LINEAR;
- MipFilter[1] = NONE; //no mipmaps.
- AddressU[1] = CLAMP;
- AddressV[1] = CLAMP;
-
- Texture[2] = <SourceTexture3>;
- MinFilter[2] = LINEAR;
- MagFilter[2] = LINEAR;
- MipFilter[2] = NONE; //no mipmaps.
- AddressU[2] = CLAMP;
- AddressV[2] = CLAMP;
-
- AlphaBlendEnable = false;
- AlphaTestEnable = false;
- FogEnable = false;
-
- CullMode = NONE;
- ZEnable = false;
- ZWriteEnable = false;
-
- VertexShader = compile vs_1_1 VSBaseScreenCorrected3();
-
- PixelShaderConstant[0] = <BlendWeight1>;
- PixelShaderConstant[1] = <BlendWeight2>;
- PixelShaderConstant[2] = <BlendWeight3>;
-
- PixelShader =
- asm
- {
- ps_1_1
-
- tex t0
- tex t1
- tex t2
-
- mul r0, c0, t0
- mad r0, c1, t1, r0
- mad r0, c2, t2, r0
- };
- }
- }
-
-
- //----------------------------------------------
- // blend of 4 textures into one
- //----------------------------------------------
- technique Blend4
- <
- int Priority = 1;
- int TechniqueIndex = 202;
- int DeviceType = HWSHADER_ONLY;
- int LightingType = INTEGRATED_LIGHTING;
- string RenderingType = "Standard";
- >
- {
- pass pass1
- {
- Texture[0] = <SourceTexture1>;
- MinFilter[0] = LINEAR;
- MagFilter[0] = LINEAR;
- MipFilter[0] = NONE; //no mipmaps.
- AddressU[0] = CLAMP;
- AddressV[0] = CLAMP;
-
- Texture[1] = <SourceTexture2>;
- MinFilter[1] = LINEAR;
- MagFilter[1] = LINEAR;
- MipFilter[1] = NONE; //no mipmaps.
- AddressU[1] = CLAMP;
- AddressV[1] = CLAMP;
-
- Texture[2] = <SourceTexture3>;
- MinFilter[2] = LINEAR;
- MagFilter[2] = LINEAR;
- MipFilter[2] = NONE; //no mipmaps.
- AddressU[2] = CLAMP;
- AddressV[2] = CLAMP;
-
- Texture[3] = <SourceTexture4>;
- MinFilter[3] = LINEAR;
- MagFilter[3] = LINEAR;
- MipFilter[3] = NONE; //no mipmaps.
- AddressU[3] = CLAMP;
- AddressV[3] = CLAMP;
-
- AlphaBlendEnable = false;
- AlphaTestEnable = false;
- FogEnable = false;
-
- CullMode = NONE;
- ZEnable = false;
- ZWriteEnable = false;
-
- VertexShader = compile vs_1_1 VSBaseScreenCorrected4();
-
- PixelShaderConstant[0] = <BlendWeight1>;
- PixelShaderConstant[1] = <BlendWeight2>;
- PixelShaderConstant[2] = <BlendWeight3>;
- PixelShaderConstant[3] = <BlendWeight4>;
-
- PixelShader =
- asm
- {
- ps_1_1
-
- tex t0
- tex t1
- tex t2
- tex t3
-
- mul r0, c0, t0
- mad r0, c1, t1, r0
- mad r0, c2, t2, r0
- mad r0, c3, t3, r0
- };
- }
- }
-
-
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------------------------
-